<?php

// STANDARD Data Sheet VARIABLES
$dsProductName = get_post_meta($post->ID, 'ProductName', true);
$dsProductSku = get_post_meta($post->ID, 'ProductSku', true);
$dsProductWarranty = get_post_meta($post->ID, 'ProductWarranty', true);
if (get_post_meta($post->ID, 'ProductSRCC', true) == 'OG-100' || get_post_meta($post->ID, 'ProductSRCC', true)) {
	if (get_post_meta($post->ID, 'ProductSRCC', true) == 'OG-100') {
		$dsProductSRCC = 'This Product Is SRCC OG-100 Certified';
	} elseif (get_post_meta($post->ID, 'ProductSRCC', true) == 'OG-300') {
		$dsProductSRCC = 'This Product Is SRCC OG-300 Certified';
	}
} else {
	$dsProductSRCC = '';
}
if (get_post_meta($post->ID, 'ProductKeymark', true) == 'Yes') {
	$dsProductKeymark = 'This Product Is Solar Keymark Certified';
} else {
	$dsProductKeymark = '';
}
if (get_post_meta($post->ID, 'ProductCSA', true)) {
	$dsProductCSA = 'This Product Is CSA Certified';
} else {
	$dsProductCSA = '';
}
$dsProductImages = get_post_meta($post->ID, 'ProductDSImages', true);
$dsProductImage = get_post_meta($post->ID, 'ProductDSMainImage', true);
if (get_post_meta($post->ID, 'ProductDSAddImageOne', true)) {
	$dsProductImageAddOne = get_post_meta($post->ID, 'ProductDSAddImageOne', true);
} else {
	$dsProductImageAddOne = '';
}
if (get_post_meta($post->ID, 'ProductDSAddImageTwo', true)) {
	$dsProductImageAddTwo = get_post_meta($post->ID, 'ProductDSAddImageTwo', true);
} else {
	$dsProductImageAddTwo = '';
}
if (get_post_meta($post->ID, 'ProductDSAddImageThree', true)) {
	$dsProductImageAddThree = get_post_meta($post->ID, 'ProductDSAddImageThree', true);
} else {
	$dsProductImageAddThree = '';
}
if (get_post_meta($post->ID, 'ProductDSAddImageFour', true)) {
	$dsProductImageAddFour = get_post_meta($post->ID, 'ProductDSAddImageFour', true);
} else {
	$dsProductImageAddFour = '';
}
if (get_post_meta($post->ID, 'ProductDSAddImageOne', true)) {
	$dsProductImageAddFive = get_post_meta($post->ID, 'ProductDSAddImageFive', true);
} else {
	$dsProductImageAddFive = '';
}
$dsProductTableOneTitle = get_post_meta($post->ID, 'ProductDSTableOneTitle', true);
$dsProductTableOneContent = get_post_meta($post->ID, 'ProductDSTableOneContent', true);
if (get_post_meta($post->ID, 'ProductDSTableTwoTitle', true)) {
	$dsProductTableTwoTitle = get_post_meta($post->ID, 'ProductDSTableTwoTitle', true);
	$dsProductTableTwoContent = get_post_meta($post->ID, 'ProductDSTableTwoContent', true);
} else {
	$dsProductTableTwoTitle = '';
	$dsProductTableTwoContent = '';
}
if (get_post_meta($post->ID, 'ProductDSTableThreeTitle', true)) {
	$dsProductTableThreeTitle = get_post_meta($post->ID, 'ProductDSTableThreeTitle', true);
	$dsProductTableThreeContent = get_post_meta($post->ID, 'ProductDSTableThreeContent', true);
} else {
	$dsProductTableThreeTitle = '';
	$dsProductTableThreeContent = '';
}
if (get_post_meta($post->ID, 'ProductDSTableFourTitle', true)) {
	$dsProductTableFourTitle = get_post_meta($post->ID, 'ProductDSTableFourTitle', true);
	$dsProductTableFourContent = get_post_meta($post->ID, 'ProductDSTableFourContent', true);
} else {
	$dsProductTableFourTitle = '';
	$dsProductTableFourContent = '';
}
if (get_post_meta($post->ID, 'ProductDSTableFiveTitle', true)) {
	$dsProductTableFiveTitle = get_post_meta($post->ID, 'ProductDSTableFiveTitle', true);
	$dsProductTableFiveContent = get_post_meta($post->ID, 'ProductDSTableFiveContent', true);
} else {
	$dsProductTableFiveTitle = '';
	$dsProductTableFiveContent = '';
}
if (get_post_meta($post->ID, 'ProductDSSpecText', true)) {
	$dsProductSpecText = get_post_meta($post->ID, 'ProductDSSpecText', true);
}

$pdf_html_header 			= true; //If this is ture you can write instead of the array a html string on the var $pdf_header
$pdf_html_footer 			= true; //If this is ture you can write instead of the array a html string on the var $pdf_footer

$pdf_header = '
	<table width="100%" cellpadding="0" cellspacing="0" border="0" style="display:block;position:fixed;">
		<tr>
			<td style="padding-bottom:5px;">
				<img src="images/single-print-datasheet-logo.jpg" align="left" style="padding-right:20px;border-right:#cccccc 1px solid;margin-right:20px;" />
			</td>
			<td style="padding-bottom:5px;">
				<h1>Product Data Sheet</h1>
				<h2>' . $dsProductName . '</h2>
			</td>
		</tr>
		<tr>
			<td colspan="2" style="height:5px;background:#e77d1d;"></td>
		</tr>
	</table>
';

$pdf_footer = '
	<div id="footer">
		<div id="footer-left">
			<ul>
				<li>' . $dsProductWarranty . '</li>
				<li>' . $dsProductSRCC . '</li>
				<li>' . $dsProductKeymark . '</li>
				<li>' . $dsProductCSA . '</li>
			</ul>
			<p>&copy;2012 SunMaxx Solar | Specifications Subject To Change Without Notice</p>
		</div>
		<div id="footer-right">
			<p><strong>SunMaxx Solar</strong><br />
			56 Broome Corporate Pkwy<br />
			Conklin, NY 13748<br />
			P: 1.877.786.6299<br />
			F: 1.800.786.0329<br />
			www.SunMaxxSolar.com</p>
		</div>
	</div>
';
		

	$pdf_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
		<html xml:lang="en">
		
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<title>' . get_bloginfo() . '</title>
			
		</head>
		
		<body xml:lang="en">
		
			<bookmark content="'.htmlspecialchars(get_bloginfo('name'), ENT_QUOTES).'" level="0" /><tocentry content="'.htmlspecialchars(get_bloginfo('name'), ENT_QUOTES).'" level="0" />
			
			<style>
				
				@page { size: 8.5in 11in;
					background-image: url("images/printDataSheetBodyBG.jpg");
				}
				
				body { font-family:arial;font-size:12px; }
				a { color:#002d55;text-decoration:none; }
				h2 { background:none;color:#333333;font-size:14px; }
				h3 { display:normal;background:none;font-size:15px;font-weight:bold;color:#000000;line-height:15px;margin:0px;margin-bottom:5px; }
					
				#wrapper { width:100%;padding:0px;margin:0px;background: url(http://www.sunmaxxsolar.com/wp-content/wp-mpdf-themes/images/printDataSheetBodyBG.jpg); }
				
				#background { width:100%;height:100%;position:fixed;top:0px;
				
				#header { width:700px;height:130px; }
				#header-left { width:400px;float:left;margin:0px; }
					#header-left img { margin:0px;clear:none; }
				#header-right-address { width:270px;float:right;margin:0px;text-align:right; }
				
				#spectable td { width:200px;height:30px;vertical-align:middle; }
				
				#stampboxone { width:676px;padding:10px;background:#f2f2f2;" }
				
				#printRPleft { width:60%;float:left;margin:0px; }
				#printRPRight { width:35%;float:right;margin:0px;padding-top:3px; }
					#printRPRightQuick { width:95%;padding:2%;border:#cccccc .5% solid;background:#f2f2f2; }
						#printRPRightQuick ul { list-style:none;padding:0px;margin:0px;font-size:10px;width:100%; }
							#printRPRightQuick ul li { display:block;width:100%;height:20px;line-height:20px;font-weight:bold; }
								#printRPRightQuick span { text-align:right !important;font-weight:normal; }
								
				#footer { width:100%;border-top:#666666 1px solid; }
					#footer p { font-size:12px;color:#666666; }
					#footer-left { width:65%;float:left;margin:0px; }
					#footer-right { width:30%;float:right;margin:0px;border-left:#666666 1px solid;text-align:right; }
				
				
			</style>
		';
			
			while (have_posts()) : the_post();

				$pdf_output .= '
			
			<table width="100%" cellpadding="0" cellspacing="0" border="0" style="page-break-after:always;">
				<tr>
					<td height="120"></td>
				</tr>
				<tr>
					<td height="780" valign="top">
						<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-size:11px;">
							<tr>
								<td width="400px">';
									// Include Spec Table 1
									if (get_post_meta($post->ID, 'ProductDSTableOneTitle', true)) {
										$pdf_output .= '
											<h3>' .$dsProductTableOneTitle . '</h3>
											<table class="spectable" width="400px" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:20px">
												' . $dsProductTableOneContent . '
											</table>
									'; }
									// Include Spec Table 1
									if (get_post_meta($post->ID, 'ProductDSTableTwoTitle', true)) {
										$pdf_output .= '
											<h3>' .$dsProductTableTwoTitle . '</h3>
											<table class="spectable" width="400px" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:20px;">
												' . $dsProductTableTwoContent . '
											</table>
									'; }
									// Include Spec Table 1
									if (get_post_meta($post->ID, 'ProductDSTableThreeTitle', true)) {
										$pdf_output .= '
											<h3>' .$dsProductTableThreeTitle . '</h3>
											<table class="spectable" width="400px" cellpadding="0" cellspacing="0" border="0">
												' . $dsProductTableThreeContent . '
											</table>
									'; }
									// Include Spec Table 1
									if (get_post_meta($post->ID, 'ProductDSTableFourTitle', true)) {
										$pdf_output .= '
											<h3>' .$dsProductTableFourTitle . '</h3>
											<table class="spectable" width="400px" cellpadding="0" cellspacing="0" border="0">
												' . $dsProductTableFourContent . '
											</table>
									'; }
									// Include Spec Table 1
									if (get_post_meta($post->ID, 'ProductDSTableFiveTitle', true)) {
										$pdf_output .= '
											<h3>' .$dsProductTableFiveTitle . '</h3>
											<table class="spectable" width="400px" cellpadding="0" cellspacing="0" border="0">
												' . $dsProductTableFiveContent . '
											</table>
									'; }
				$pdf_output .= '</td>
								<td width="10%"></td>
								<td width="260px" valign="top" style="text-align:right;">
									' . $dsProductImages . '
								</td>
							<tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="1" bgcolor="#999999"></td>
				</tr>
			</table>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td height="120"></td>
				</tr>
				<tr>
					<td height="780" valign="top">
						<h3 style="margin-bottom:10px">Recommended Spec Text</h3>
						<table width="676" cellpadding="10" cellspacing="0" border="0">
							<tr>
								<td height="1"></td>
							</tr>
							<tr>
								<td width="656" height="150" bgcolor="#f2f2f2" valign="top" style="border:#cccccc 1px solid;">
									' . $dsProductSpecText . '
								</td>
							</tr>
							<tr>
								<td height="1"></td>
							</tr>
						</table>
						<h3 style="margin-bottom:10px">Architectural Stamps &amp; Remarks</h3>
						<table width="676" cellpadding="10" cellspacing="0" border="0">
							<tr>
								<td height="1"></td>
							</tr>
							<tr>
								<td width="656" height="150" bgcolor="#f2f2f2" valign="top" style="border:#cccccc 1px solid;">
									
								</td>
							</tr>
							<tr>
								<td height="1"></td>
							</tr>
						</table>
						<h3 style="margin-bottom:10px">Contractor Stamp &amp; Notes</h3>
						<table width="676" cellpadding="10" cellspacing="0" border="0">
							<tr>
								<td height="1"></td>
							</tr>
							<tr>
								<td width="656" height="150" bgcolor="#f2f2f2" valign="top" style="border:#cccccc 1px solid;">
									
								</td>
							</tr>
							<tr>
								<td height="1"></td>
							</tr>
						</table>
						<h3 style="margin-bottom:10px">Contractor Note - Sign Below</h3>
						<table width="676" cellpadding="10" cellspacing="0" border="0">
							<tr>
								<td height="1"></td>
							</tr>
							<tr>
								<td width="656" height="75" bgcolor="#f2f2f2" valign="top" style="border:#cccccc 1px solid;">
									
								</td>
							</tr>
							<tr>
								<td height="1"></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="1" bgcolor="#999999"></td>
				</tr>
			</table>
				';
				
		endwhile ;
	
	$pdf_output .= '
		</body>
		</html>';
?>
